//
//  ZBHomeItemCell.m
//  ZBCooking
//
//  Created by xzb on 2019/2/18.
//  Copyright © 2019 xzb. All rights reserved.
//

#import "ZBHomeItemCell.h"

@interface ZBHomeItemCell ()

@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (nonatomic, strong) NSDictionary *info;
@end
@implementation ZBHomeItemCell
- (void)awakeFromNib
{
    [super awakeFromNib];
    
//    self.bgView.layer.masksToBounds = YES;
//    self.bgView.layer.borderColor = [UIColor grayColor].CGColor;
//    self.bgView.layer.borderWidth = 1;
    
    self.bgView.layer.cornerRadius  = 10;
    self.bgView.layer.shadowColor  = [UIColor blackColor].CGColor;
    self.bgView.layer.shadowOffset  = CGSizeMake(0, 5);
    self.bgView.layer.shadowOpacity = 0.3f;
    self.bgView.layer.shadowRadius  = 10.0f;
    
}

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    NSArray *list = [self.info zb_safeArrayValueForKey:@"sub_items" defaultValue:@[]];
    if (list.count == 0) {
        [ZBToast showToast:@"暂时没有数据"];
        return;
    }
    [ZBRouter openURL:@"xzb/list" withUserInfo:@{
                                                    @"item" : self.info
                                                    } completion:nil];
}
#pragma mark - BDCellInfoProtocol

- (void)loadData:(id)data
{
    self.info = data;
    self.titleLabel.text = data[@"title"];
}

+ (CGFloat)cellHeight:(id)model
{
    return 100;
}

+ (CGSize)itemSize:(id)data
{
    return CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds)  * 0.5 - 20, 100);
}

@end
